﻿var HtmlEditor=parent.fastCSharp.Object[fastCSharp.Query.id],Type=parseInt(fastCSharp.Query.type);
var FormatWidthHeight=function(Value,DefaultValue)
	{
	return (Value=parseInt(0+Value,10))<DefaultValue/3?DefaultValue:Value;
	};
var FlashCode=function(Url,Width,Height)
	{
	var Src=Url.ToHTML(),WidthHeight=(arguments.length&&Width?" width='"+Width+"'":'')+(arguments.length>1&&Height?" height='"+Height+"'":'');
	return "<object type='applicatione/x-shockwave-flash' data='"+Src+"'"+WidthHeight+"><embed type='applicatione/x-shockwave-flash' src='"+Src+"'"+WidthHeight+'></embed></object>';
	};
var MediaCode=function(Url,Width,Height)
	{
	return "<embed src='"+Url.ToHTML()+"' width='"+Width+"' height='"+Height+"' autostart='false' loop='false'></embed>";
	};
var RealCode=function(Url,Width,Height)
	{
	return MediaCode(Url,Width,Height);
	};
var Show=function()
	{
	var Html='',Value=Form.GetValue();
	if(Type==0)	Html=FlashCode(Value.Path,Value.Width,Value.Height);
	else if(Type==1)	Html=MediaCode(Value.Path,Value.Width,Value.Height);
	else if(Type==2)	Html=RealCode(Value.Path,Value.Width,Value.Height);
	HtmlEditor.PasteHtml("<span style='display:none'></span>"+Html,0);
	HtmlEditor.ShowOver();
	};
var LoadForm=function()
	{
	fastCSharp.$Id('Remark_span').Html(['Flash动画','MediaPlayer播放器','Real Media播放器'][Type]);
	fastCSharp.$Id('File_span').Html(['','avi,wmv,asf,mov','rm,ra,ram'][Type]);
	if(!Type)
		{
		fastCSharp.$Id('File_Tr').Display(0);
		fastCSharp.$Id('Play_span').Display(0);
		}
	var Elements={
		Path:	{
			MaxLength:256,
			OnFormat:function(Form,Value){return HtmlEditor.FormatUrl(Value);}
			},
		Width	{
			MaxLength:3,
			DefaultValue:480,
			OnFormat:function(Form,Value){return FormatWidthHeight(Value,480);}
			},
		Height:	{
			MaxLength:3,
			DefaultValue:360,
			OnFormat:function(Form,Value){return FormatWidthHeight(Value,360);}
			}
		};
	window.Form=fastCSharp.NewObject('Form',{FormId:'Form',DefaultValue:{Path:'http://'},Elements:Elements,Buttons:[{Id:'ReturnButton',OnClick:Show}]});
	Form.Start();
	};
fastCSharp.OnLoad(LoadForm,null,1);
